<?php 
    include('../header.php');

    $account=$_POST['account'];//post获取表单里的account
    $password=$_POST['password'];
    $userName=$_POST['userName'];
    $email=$_POST['email'];
    $position=$_POST['position'];
    $role=$_POST['role'];
    
    if( !($account && $password && $userName && $email && $position && $role) ){
        $res['msg']['en'] = 'Error: Incomplete information';
        $res['msg']['cn'] = 'Error: 信息填写不完整';
        echo json_encode($res);
        die();
    }
    
    include('../connect.php');//链接数据库
    $email =  $email.'@dhhtgroup.com';
    $q="insert into user(account,password,userName,email,position,role) values ('$account','$password','$userName','$email','$position','$role')";//向数据库插入表单传来的值的sql
    $reslut=mysql_query($q,$con);//执行sql
    

    if (!$reslut){
        $res['msg']['en'] = 'Error: Error occurred'.  mysql_error();
        $res['msg']['cn'] = 'Error: 出现错误'.  mysql_error();
        echo json_encode($res);
        die();
    }else{
        $res['status'] = 1;//成功输出注册成功
    }

    echo json_encode($res);
    mysql_close($con);//关闭数据库
?>